package com.lehecai.core.search.entity;

import com.lehecai.core.search.converter.ISearchEntityPropertyConverter;

/**
 * 字段定义
 * @author hanwenda
 *
 */
public class SearchEntityPropertyDefine {

	/**
	 * 在搜索服务中的字段名
	 */
	private String name;
	
	/**
	 * 是否已废弃，如果标记为已废弃，则各种转换时不处理此属性
	 */
	private boolean deprecated;
	
	/**
	 * 对应属性名称
	 */
	private String propertyName;

    /**
     * 原始属性名称
     */
    private String sourcePropertyName;

    /**
     * 在归档实体中的属性名称
     */
    private String archivePropertyName;

    /**
     * 属性转换器
     */
    private ISearchEntityPropertyConverter converter;

    /**
     * 为归档数据的属性转换留下扩展
     */
    private ISearchEntityPropertyConverter archiveConverter;
	
	public SearchEntityPropertyDefine(String name) {
		this(name, name);
	}

    public SearchEntityPropertyDefine(String name, ISearchEntityPropertyConverter converter) {
        this(name, name, converter);
    }

    public SearchEntityPropertyDefine(String name, String propertyName, ISearchEntityPropertyConverter converter) {
        this(name, false, propertyName, propertyName, propertyName, converter);
    }

	public SearchEntityPropertyDefine(String name, String propertyName) {
		this(name, false, propertyName);
	}

    public SearchEntityPropertyDefine(String name, boolean deprecated, String propertyName) {
        this(name, deprecated, propertyName, propertyName);
    }

    public SearchEntityPropertyDefine(String name, boolean deprecated, String propertyName, String archivePropertyName) {
        this(name, deprecated, propertyName, archivePropertyName, null);
    }

    public SearchEntityPropertyDefine(String name, boolean deprecated, String propertyName, String archivePropertyName, ISearchEntityPropertyConverter converter) {
        this(name, deprecated, propertyName, propertyName, archivePropertyName, converter, null);
    }

    public SearchEntityPropertyDefine(String name, boolean deprecated, String propertyName, String sourcePropertyName, String archivePropertyName, ISearchEntityPropertyConverter converter) {
        this(name, deprecated, propertyName, sourcePropertyName, archivePropertyName, converter, null);
    }

    public SearchEntityPropertyDefine(String name, boolean deprecated, String propertyName, String sourcePropertyName, String archivePropertyName, ISearchEntityPropertyConverter converter, ISearchEntityPropertyConverter archiveConverter) {
        this.setName(name);
        this.setDeprecated(deprecated);
        this.setPropertyName(propertyName);
        this.setSourcePropertyName(sourcePropertyName);
        this.setArchivePropertyName(archivePropertyName);
        this.setConverter(converter);
        this.setArchiveConverter(archiveConverter);
    }
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public boolean isDeprecated() {
		return deprecated;
	}

	public void setDeprecated(boolean deprecated) {
		this.deprecated = deprecated;
	}

	public String getPropertyName() {
		return propertyName;
	}

	public void setPropertyName(String propertyName) {
		this.propertyName = propertyName;
	}

    public String getArchivePropertyName() {
        return archivePropertyName;
    }

    public void setArchivePropertyName(String archivePropertyName) {
        this.archivePropertyName = archivePropertyName;
    }

    public ISearchEntityPropertyConverter getConverter() {
        return converter;
    }

    public void setConverter(ISearchEntityPropertyConverter converter) {
        this.converter = converter;
    }

    public ISearchEntityPropertyConverter getArchiveConverter() {
        return archiveConverter;
    }

    public void setArchiveConverter(ISearchEntityPropertyConverter archiveConverter) {
        this.archiveConverter = archiveConverter;
    }

    public String getSourcePropertyName() {
        return sourcePropertyName;
    }

    public void setSourcePropertyName(String sourcePropertyName) {
        this.sourcePropertyName = sourcePropertyName;
    }
}
